import type { PageParam, PageResult } from '@vben/request';

import { requestClient } from '#/api/request';

export namespace ServiceCategoryApi {
  /** 服务分类信息 */
  export interface ServiceCategory {
    id?: number; // ID
    communityId?: number; // 社区ID
    merchantId?: number; // 商户ID
    name: string; // 分类名称
    icon?: string; // 分类图标
    sort?: number; // 排序
    createTime?: string; // 创建时间
  }
}

/** 查询服务分类分页 */
export function getServiceCategoryPage(params: PageParam) {
  return requestClient.get<PageResult<ServiceCategoryApi.ServiceCategory>>(
    '/cmt/service-category/page',
    { params },
  );
}

/** 查询服务分类详情 */
export function getServiceCategory(id: number) {
  return requestClient.get<ServiceCategoryApi.ServiceCategory>(
    `/cmt/service-category/get?id=${id}`,
  );
}

/** 新增服务分类 */
export function createServiceCategory(data: ServiceCategoryApi.ServiceCategory) {
  return requestClient.post('/cmt/service-category/create', data);
}

/** 修改服务分类 */
export function updateServiceCategory(data: ServiceCategoryApi.ServiceCategory) {
  return requestClient.put('/cmt/service-category/update', data);
}

/** 删除服务分类 */
export function deleteServiceCategory(id: number) {
  return requestClient.delete(`/cmt/service-category/delete?id=${id}`);
}

/** 批量删除服务分类 */
export function deleteServiceCategoryList(ids: number[]) {
  return requestClient.delete(
    `/cmt/service-category/delete-list?ids=${ids.join(',')}`,
  );
}

/** 导出服务分类 */
export function exportServiceCategory(params: any) {
  return requestClient.download('/cmt/service-category/export-excel', { params });
}

/** 获取服务分类选项列表(用于下拉选择) */
export function getServiceCategoryOptions() {
  return requestClient.get<PageResult<ServiceCategoryApi.ServiceCategory>>(
    '/cmt/service-category/page',
    { params: { pageNo: -1, pageSize: 10 } },
  );
}
